package net.yeah.mickey_zhouyou.module.booklist.ui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JToolBar;

import net.yeah.mickey_zhouyou.module.booklist.util.Constants;

public class BookListPane extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7874557045227207760L;

	private static final BookListPane pane = new BookListPane();

	private BookListPane() {
		super.setLayout(new BorderLayout());

		super.add(new JScrollPane(new JTable(new BookTableModel())),
				BorderLayout.CENTER);

		super.add(makeTookBar(), BorderLayout.EAST);
	}

	public static BookListPane getPane() {
		return pane;
	}

	private JToolBar makeTookBar() {
		JToolBar bar = new JToolBar();
		bar.add(new AbstractAction() {
			private static final long serialVersionUID = -7978813637790832355L;
			{
				super.putValue(Action.SMALL_ICON, new ImageIcon(
						Constants.ICON_PATH_ADD_BOOKINFO));
			}

			public void actionPerformed(ActionEvent e) {
				BookDialog.getDialog().setVisible(true);
			}
		});
		bar.add(new AbstractAction() {
			private static final long serialVersionUID = -7978813637790832355L;
			{
				super.putValue(Action.SMALL_ICON, new ImageIcon(
						Constants.ICON_PATH_MOD_BOOKINFO));
			}

			public void actionPerformed(ActionEvent e) {
			}
		});
		bar.add(new AbstractAction() {
			private static final long serialVersionUID = -7978813637790832355L;
			{
				super.putValue(Action.SMALL_ICON, new ImageIcon(
						Constants.ICON_PATH_FIRST_BOOK));
			}

			public void actionPerformed(ActionEvent e) {
			}
		});
		bar.add(new AbstractAction() {
			private static final long serialVersionUID = -7978813637790832355L;
			{
				super.putValue(Action.SMALL_ICON, new ImageIcon(
						Constants.ICON_PATH_UP_BOOK));
			}

			public void actionPerformed(ActionEvent e) {
			}
		});
		bar.add(new AbstractAction() {
			private static final long serialVersionUID = -7978813637790832355L;
			{
				super.putValue(Action.SMALL_ICON, new ImageIcon(
						Constants.ICON_PATH_DOWN_BOOK));
			}

			public void actionPerformed(ActionEvent e) {
			}
		});
		bar.add(new AbstractAction() {
			private static final long serialVersionUID = -7978813637790832355L;
			{
				super.putValue(Action.SMALL_ICON, new ImageIcon(
						Constants.ICON_PATH_LAST_BOOK));
			}

			public void actionPerformed(ActionEvent e) {
			}
		});
		bar.setOrientation(JToolBar.VERTICAL);
		return bar;
	}

}
